/**
 * Created by lavsql on 2017/7/15.
 */
import Vue from 'vue'
import Vuex from 'vuex'

// import EcHttpUtils from '@/common/js/EcHttpUtils'
Vue.use(Vuex)

const state = {
  standards: [],
  show: 1,
  cartsize: 0,
  ordertype: ''
}

const getters = {
  stime: function () {
    var mydate = new Date()
    return mydate.getTime()
  }
}

const mutations = {
  setcartsize (state, obj) {
    state.cartsize = obj.size
    console.log(obj)
  },
  setOrderType (state, obj) {
    state.ordertype = obj.ordertype
    console.log(obj)
  },
  getitems: function () {
    // EcHttpUtils.get('cart/detail.json').then(function (resp) {
    //   let arr = resp.data.data
    //   let cartsize = 0
    //   arr.cartItems.forEach(function (val, k) {
    //     val.items.forEach(function (v, k) {
    //       v.price = v.amount / v.size
    //       cartsize = cartsize + 1
    //     })
    //     if (val.coupon) {
    //       val.remain = val.amount - val.coupon.price // 活动还差
    //     }
    //   })
    //   state.cartItems = arr.cartItems
    //   state.cartsize = cartsize
    // })
  }
}

export default new Vuex.Store({
  state,
  getters,
  mutations
})
